package com.botao.tip.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.botao.tip.dao.DepartmentMapper;
import com.botao.tip.entity.Department;
import com.botao.tip.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author : vip865047755@126.com
 * @version :JDK1.8
 * @date : 2020/12/2 22:48
 * @File : DepartmentServiceImpl.java
 * @software: IntelliJ IDEA
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements DepartmentService {

    @Autowired
    private DepartmentMapper deptMapper;


    @Override
    public List<Department> queryAll() {
        return deptMapper.selectList(new QueryWrapper<Department>());
    }

    @Override
    public Department queryAllById(int departmentId) {
        return deptMapper.selectOne(new QueryWrapper<Department>().eq("departmentId", departmentId));
    }

    @Override
    public int addDepartment(String department) {
        Department depart = new Department();
        depart.setDepartment(department);
        return deptMapper.insert(depart);
    }

}
